﻿Imports Negocio
Imports Servicios

Public Class frmConsultaBitacora

    Protected Overrides Sub PreLoad()
        dgvBitacoras.AutoGenerateColumns = False
        Me.Icon = Icon.FromHandle(Global.SIPRO.My.Resources.Resources.log.GetHicon())
    End Sub

    Private Sub frmConsultaBitacora_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load        
        dtFdesde.Value = DateTime.Now
        dtFhasta.Value = DateAdd(DateInterval.Day, 1, DateTime.Now)
        Try
            Dim usus As List(Of Usuario) = GesUsuarios.Consultar(Nothing, True)
            cbUsuarios.DataSource = usus
        Catch ex As Exception
            My.Application.HandlerException(ex)
            Me.Close()
        End Try
        Search()
    End Sub

    Sub Search()
        Try
            Dim usu As New Usuario()
            usu.OID = Nothing
            If TypeOf cbUsuarios.SelectedItem Is Usuario Then
                usu = DirectCast(cbUsuarios.SelectedItem, Usuario)
            End If

            Dim bitacoras As New List(Of Bitacora)
            bitacoras = GesBitacoras.Consultar(usu, dtFdesde.Value, dtFhasta.Value)
            dgvBitacoras.DataSource = bitacoras

        Catch ex As Exception
            My.Application.HandlerException(ex)
            Me.Close()
        End Try
    End Sub

    Private Sub btnBuscar_Click(sender As System.Object, e As System.EventArgs) Handles btnBuscar.Click
        If MyBase.ValidateForm() Then
            Search()
        End If

    End Sub

    Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCerrar.Click
        Me.Close()
    End Sub
End Class